<!-- 企业承诺 -->
<script lang="ts" setup>
import { whManagerBsTbCommitmentGetCommitment } from "@/genapi/wh";
import { useUserStore } from '@/stores/user';
import { onMounted, ref } from "vue";
defineOptions({ name: 'Commitment' });

const buttontype1 = ref('primary')
const buttontype2 = ref('')
const buttontype3 = ref('')
const userStore = useUserStore();
const commit = ref('')
const getCommit = async(type='1') => {
  if(type == '1'){
    buttontype1.value = 'primary'
    buttontype2.value = ''
    buttontype3.value = ''
  }
  if(type == '2'){
    buttontype1.value = ''
    buttontype2.value = 'primary'
    buttontype3.value = ''
  }
  if(type == '3'){
    buttontype1.value = ''
    buttontype2.value = ''
    buttontype3.value = 'primary'
  }
  let res = await whManagerBsTbCommitmentGetCommitment({
    query: {
      enterpriseId: userStore.userInfo?.systemUser?.relatedId,
      type: type
  }
})
  commit.value = res.data
}
onMounted(() => {
  getCommit()
})
</script>

<template>
  <div bg="#fff" flex="~ col" p="x-30px t-24px b-12px" of="hidden">
    <div flex="~ justify-between" text="#303133 20px" font="bold" pb="12px">
      <span>企业承诺</span>
    </div>
    <div flex="~" p="b-15px">
      <el-button text :type="buttontype1" @click="getCommit('1')">每日安全承诺</el-button>
      <el-button text :type="buttontype2" @click="getCommit('2')">年初承诺</el-button>
      <el-button text :type="buttontype3" @click="getCommit('3')">年度履诺报告</el-button>
    </div>
    <el-scrollbar bg="#F7F8FA" rd="2px" text="#3B445B!" h="273px!">
      <div p="x-24px y-20px">{{ commit.commitDesc }}</div>
      <div flex="~ justify-end" p="x-24px y-20px t-80px">
        <div flex="~ col items-end">
          <span>主要负责人： {{commit.createBy}} </span>
          <span> {{ commit.createTime }} </span>
        </div>
      </div>
    </el-scrollbar>
  </div>
</template>
